
/*var groupName="小白组";
var reg = RegExp(/A组/);
alert('reg.test(groupName)=' + (reg.test(groupName)));*/


$(function () {
//资讯+++++++++++++++++++++++++++++++++++++++++++++++++++++
    function zixun() {
        $.post("news/zixun",{}, function (result) {
            $(".inews ul").empty();
            var $zixun = $(".inews ul");
            $.each(result, function (index, news) {
                //var c = escape(news.content);
                //var t = escape(news.title);
                //alert(news.title);
                var reg = RegExp(/特惠/);
                var $tr = $('<li></li>');
                if (!reg.test(news.title)) {
                    $tr.append($('<span>[ 公告 ]</span>'))
                        .append($('<a href="javascript:;" class="zixunnr" data-title="'+news.title+'" data-content="'+news.content+'">' + news.title + '</a>'))
                } else {
                    $tr.append($('<span>[ 特惠 ]</span>'))
                        .append($('<a href="javascript:;" class="zixunnr" data-title="'+news.title+'" data-content="'+news.content+'">' + news.title + '</a>'))
                }
                $('.inews ul').append($tr);
            });
            $(".zixunnr").click(function () {
                location.href="zixun.html";
                localStorage.num=2;
                localStorage.title=$(this).data("title");
                localStorage.content=$(this).data("content");
            })
        })
    }
    zixun();

    $(".gengduo").click(function () {
        location.href="zixun.html";
        localStorage.num=1;
    });
    



    
    
    function fenkuai() {
        var $fenceng = $("#fenceng");
        $.post("news/spfenlei2",{},function (data) {
            $.each(data[0],function (index1,product1) {
                $fenceng.append($('<div class="i_t mar_10">\n' +
                    '            <span class="floor_num">'+(index1+1)+'F</span>\n' +
                    '            <span class="fl">'+product1.name+'</span>\n' +
                    '            <span class="i_mores fr"></span>\n' +
                    '        </div>' +
                    '<div class="content">\n' +
                    '            <div class="fresh_left">\n' +
                    '                <div class="fre_ban">\n' +
                    '                    <div id="imgPlay1">\n' +
                    '                        <ul class="imgs" id="actor'+(index1+1)+'">\n' +
                    '                            <li><a href="#"><img src="../../images/fre_3.jpg" width="211" height="286"/></a></li>\n' +
                    '                            <li><a href="#"><img src="../../images/fre_1.jpg" width="211" height="286"/></a></li>\n' +
                    '                            <li><a href="#"><img src="../../images/fre_2.jpg" width="211" height="286"/></a></li>\n' +
                    '                        </ul>\n' +
                    '                        <div class="prevf">上一张</div>\n' +
                    '                        <div class="nextf">下一张</div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '                <div class="fresh_txt">\n' +
                    '                    <div class="fresh_txt_c">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="fresh_mid">\n' +
                    '                <ul>\n' +
                    '                </ul>\n' +
                    '            </div>\n' +
                    '            <div class="fresh_right">\n' +
                    '                <ul>\n' +
                    '                    <li><a href="#"><img src="../../images/fre_b1.jpg" width="260" height="220"/></a></li>\n' +
                    '                    <li><a href="#"><img src="../../images/fre_b2.jpg" width="260" height="220"/></a></li>\n' +
                    '                </ul>\n' +
                    '            </div>\n' +
                    '        </div>'));


                $.each(data[1],function (index2,product2) {
                    if(product1.id==product2.parentid) {
                        $(".i_mores").eq(index1+1).append($('<a href="#" style="padding-right: 20px;color: blue">' + product2.name + '</a>&nbsp; &nbsp; &nbsp;'));

                        $.each(data[2], function (index3, product3) {
                            if (product2.id == product3.parentid) {
                                $(".fresh_txt_c").eq(index1).append($('<a href="#">' + product3.name + '</a>'))
                            }
                        })
                    }
                })


                $.each(data[3],function (index4,product4) {

                    var i=1;
                    if (product1.id == product4.categorylevel1id && i<7 && product4.stock>0) {

                        $(".fresh_mid ul").eq(index1).append($('<li>\n' +
                            '                        <div class="name"><a href="#">'+product4.name+'</a></div>\n' +
                            '                        <div class="price">\n' +
                            '                            <font>￥<span>'+product4.price+'</span></font> &nbsp; 库存：'+product4.stock +
                            '                        </div>\n' +
                            '                        <div class="img"><a href="#"><img data-id="'+product4.id+'" class="imgSP"  src="../../files/'+product4.filename+'" width="185" height="155"/></a></div>\n' +
                            '                    </li>'));
                        i++;
                    }
                })

            })
            $(".imgSP").click(function () {
                location.href="http://localhost:7777/Product.html?id="+$(this).data('id');
            })
        })
    }
    
    fenkuai();



})